<template>
	<el-col :span="span" :style="span == '0.1' ? 'width:auto;' : ''">
		<el-form-item :label="label" :prop="prop">
			<el-input v-model="form[prop]" @blur="handerBlur($event)" @keyup.enter.native="handleenter" :disabled="disabled" :maxlength="maxlength"
			 :clearable="clearable" :placeholder="placeholder?placeholder:('请输入' + label)" :type="type == 'number'?'number':'text'" v-if="!type || type == 'input' || type == 'number'">
				<template slot="append" v-if="unit">{{ unit }}</template>
			</el-input>


      <el-input v-model="form[prop]" @blur="handerBlur($event)" @keyup.enter.native="handleenter" :disabled="disabled" :maxlength="maxlength"
       :clearable="clearable" :placeholder="placeholder?placeholder:('请输入' + label)" type="password" v-if="type && type == 'password'">
      	<template slot="append" v-if="unit">{{ unit }}</template>
      </el-input>

			<el-input type="textarea" :maxlength="1000" :disabled="disabled" :clearable="clearable" v-model="form[prop]"
			 :placeholder="placeholder?placeholder:('请输入' + label)" :rows="rows || 4"  v-if="type == 'textarea'" />
			<el-select class="w_100" v-model="form[prop]"  :disabled="disabled" @change="handerChange($event)" :multiple="multiple"
			 :clearable="clearable" :filterable="filterable" placeholder="请选择" v-if="type == 'select'" :loading="loading">
				<el-option v-for="item in seleDatas" :key="item[seleKey]" :label="item[seleName]" :value="item[seleKey]" :disabled="item.disabled"></el-option>
			</el-select>
			<el-date-picker style="width: 100%" :disabled="disabled" :clearable="clearable" value-format="yyyy-MM-dd" v-if="type == 'day'" v-model="form[prop]" type="date"
			 placeholder="选择日期"></el-date-picker>

			<el-date-picker style="width: 100%" :disabled="disabled" :clearable="clearable" value-format="yyyy-MM-dd" v-if="type == 'daterange'" v-model="form[prop]" type="daterange"
			 range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" @blur="changeRange"></el-date-picker>

			<el-radio-group v-model="form[prop]" v-if="type == 'radios'" @change="radio_change($event)" :disabled="disabled">
				<el-radio label="0">{{ radioyes }}</el-radio>
				<el-radio label="1">{{ radiono }}</el-radio>
			</el-radio-group>
			<el-radio-group v-model="form[prop]" v-if="type == 'radioss'" @change="radio_change($event)" :disabled="disabled">
				<el-radio :label="1">{{ radioyes }}</el-radio>
				<el-radio :label="0">{{ radiono }}</el-radio>
			</el-radio-group>
			<el-radio-group v-model="form[prop]" v-if="type == 'radiose'" @change="radio_change($event)" :disabled="disabled">
				<el-radio :label="0">{{ radioyes }}</el-radio>
				<el-radio :label="1">{{ radiono }}</el-radio>
			</el-radio-group>
		</el-form-item>
	</el-col>
</template>

<script>
	export default {
		components: {},
		data() {
			return {};
		},
		props: {
			pickerType: {
				type: String,
				default: "date",
			},
			span: {
				type: Number,
				default: 0.1,
			},
      rows: {
				type: Number,
				default: 4,
			},
			label: String,
			unit: String,
			prop: String,
			form: Object,
			type: String,
			maxlength: {
				type: String,
				default: "20",
			},
			seleDatas: {
				type: Array,
				default: function() {
					return [];
				},
			},
			seleKey: {
				type: String,
				default: "value",
			},
			seleName: {
				type: String,
				default: "label",
			},
			loading: false,
			clearable: false,
			filterable: false,
			multiple: false,
			disabled: false,
      placeholder: {
				type: String,
				default: "",
			},
			radioyes: {
				type: String,
				default: "是",
			},
			radiono: {
				type: String,
				default: "否",
			},
		},
		methods: {
			handerBlur(e){
				this.$emit("blur", e);
			},
			changeRange(e){
				this.$forceUpdate();
        this.$emit("change", e);
			},
			handerChange(e) {
				this.$emit("change", e);
			},
			radio_change(e) {
				this.$emit("change", e);
			},
			handleenter() {
				this.$emit("keyenter");
				return false;
			},
		},
		watch: {},
	};
</script>

<style scoped lang="scss">

</style>
